home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 11 / CU Amiga Magazine's Super CD-ROM 11 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-06].iso / cucd / programming / oberonv4 / source / system / host.mod (.txt) < prev    next >
Oberon Text  |  1996-05-07  |  4KB  |  81 lines

  1. Syntax10.Scn.Fnt
  2. Syntax10i.Scn.Fnt
  3. StampElems
  4. Alloc
  5. 3 May 96
  6. Syntax10m.Scn.Fnt
  7. Syntax12i.Scn.Fnt
  8. LineElems
  9. Alloc
  10. MODULE Host;    (** SHML 19 Mar 96, 
  11.         This module encapsulates all system_dependent variables and procedures of an Oberon System V4.
  12.         This is the version for Oberon for Amiga.
  13.         Created by Stefan H._M. Ludwig, Institute for Computer Systems, ETH Zurich, ludwig@inf.ethz.ch, 19 Mar 96
  14.     IMPORT Input, Display, Modules, Bitmaps;
  15.         Host-: ARRAY 32 OF CHAR;    (** string identifying the host machine *)
  16.         TimeUnit-: LONGINT;    (** resolution of Input.Time(), TimeUnit ticks happen per second *)
  17.         OptionChar-: CHAR;    (** character used by command interpreters for specifying options *)
  18.         PathChar-: CHAR;    (** character used in file names for separating subdirectories *)
  19.         backup: Bitmaps.Bitmap;
  20.     (* Support *) 
  21.     PROCEDURE Append(VAR to(*inout*): ARRAY OF CHAR; this: ARRAY OF CHAR);
  22.         (* append this to to, trim this to space left in to *)
  23.         VAR toLen, i, j: LONGINT;
  24.     BEGIN
  25.         i := -1;
  26.         REPEAT INC(i) UNTIL to[i] = 0X;
  27.         toLen := LEN(to)-1; j := 0;
  28.         WHILE (i # toLen) & (this[j] # 0X) DO to[i] := this[j]; INC(i); INC(j) END;
  29.         to[i] := 0X
  30.     END Append;
  31.     (* Exported procedures *) 
  32.     PROCEDURE Backup*(X, Y, W, H: INTEGER);
  33.         (** Backup screen area X, Y, W, H; (must not be followed by Backup) *)
  34.     BEGIN
  35.         backup := Bitmaps.New(W, H);
  36.         Bitmaps.CopyBlock(Bitmaps.Disp, backup, X, Y, W, H, 0, 0, Display.replace)
  37.     END Backup;
  38.     PROCEDURE Restore*(X, Y, W, H: INTEGER);
  39.         (** Restore screen area X, Y, W, H; (must be preceded by Backup) *)
  40.     BEGIN
  41.         IF backup # NIL THEN Bitmaps.CopyBlock(backup, Bitmaps.Disp, 0, 0, W, H, X, Y, Display.replace) END
  42.     END Restore;
  43.     PROCEDURE IsFileNameChar*(ch: CHAR): BOOLEAN;    (** Is ch part of a valid file name? *)
  44.     BEGIN
  45.         CASE ch OF
  46.         | "A".."Z", "a".."z", "0".."9", ".", "/", "_", ":": RETURN TRUE
  47.         ELSE RETURN FALSE
  48.         END
  49.     END IsFileNameChar;
  50.     PROCEDURE CallError*(command: ARRAY OF CHAR; res: INTEGER; VAR msg(*out*): ARRAY OF CHAR);
  51.         (** Translate error message when the call of command fails; (res # 0, 100); (LEN(msg) >= 32, 101) *)
  52.         VAR i, j: INTEGER;
  53.     BEGIN
  54.         ASSERT(res # 0, 100); ASSERT(LEN(msg) >= 32, 101);
  55.         IF res > 0 THEN
  56.             COPY("Call error: ", msg); Append(msg, Modules.importing);
  57.             IF res = 1 THEN Append(msg, " not found")
  58.             ELSIF res = 2 THEN Append(msg, " not an obj-file")
  59.             ELSIF res = 3 THEN
  60.                 Append(msg, " imports ");
  61.                 Append(msg, Modules.imported); Append(msg, " with bad key")
  62.             ELSIF res = 4 THEN Append(msg, " corrupted obj file")
  63.             ELSIF res = 5 THEN Append(msg, command); Append(msg, " command not found")
  64.             ELSIF res = 6 THEN Append(msg, " has too many imports")
  65.             ELSIF res = 7 THEN Append(msg, " not enough space")
  66.             END
  67.         ELSIF res < 0 THEN
  68.             i := -1;
  69.             REPEAT INC(i) UNTIL (command[i] = ".") OR (command[i] = 0X);
  70.             IF command[i] = 0X THEN i := -1 END;
  71.             j := -1; 
  72.             REPEAT INC(i); INC(j); msg[j] := command[i] UNTIL command[i] = 0X;    (* copy procedure name *)
  73.             Append(msg, " not found")
  74.         END
  75.     END CallError;
  76. BEGIN
  77.     Host := "Amiga";
  78.     OptionChar := "\"; PathChar := "/";
  79.     TimeUnit := Input.TimeUnit
  80. END Host.
  81.